package fr.univ.lille1.android;

import android.widget.FrameLayout;

import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.ViewById;

import fr.univ.lille1.android.fragments.ListCommentsFragment.OnNavigationCommentSelected;

@EActivity(R.layout.activity_comment)
public class CommentActivity extends BaseActivity implements
		OnNavigationCommentSelected {
	@ViewById(R.id.frameLayoutComments)
	FrameLayout mFrameLayoutComments;

	@AfterViews
	void afterViews() {
		if (mFrameLayoutComments != null) {
			final fr.univ.lille1.android.fragments.ListCommentsFragment_ fragment = new fr.univ.lille1.android.fragments.ListCommentsFragment_();
			getSupportFragmentManager().beginTransaction()
					.add(R.id.frameLayoutComments, fragment).commit();
		}
	}

	@Override
	public void changeToAddComment() {
		if (mFrameLayoutComments != null && mAuthentication.isAuthenticated()) {
			final fr.univ.lille1.android.fragments.AddCommentFragment_ fragment = new fr.univ.lille1.android.fragments.AddCommentFragment_();
			getSupportFragmentManager().beginTransaction()
					.replace(R.id.frameLayoutComments, fragment)
					.addToBackStack(null).commit();
		}
	}
}
